package myAsm;

import java.util.Map;

import javax.persistence.*;

import org.objectweb.asm.MethodVisitor;


@Entity
@DiscriminatorValue("INSN_LINENUMBER")
public class MyLineNumberNode extends MyAbstractInsnNode {

    /**
     * A line number. This number refers to the source file from which the class
     * was compiled.
     */
	@Column(name="LNB_LINE")
    public int line;

    /**
     * The first instruction corresponding to this line number.
     */
    @Transient
    public MyLabelNode start;

    public MyLineNumberNode() {
        super(-1);
    }
    
    /**
     * Constructs a new {@link LineNumberNode}.
     * 
     * @param line a line number. This number refers to the source file from
     *        which the class was compiled.
     * @param start the first instruction corresponding to this line number.
     */
    public MyLineNumberNode(final int line, final MyLabelNode start) {
        super(-1);
        this.line = line;
        this.start = start;
    }

    public int getType() {
        return LINE;
    }

    public void accept(final MethodVisitor mv) {
        mv.visitLineNumber(line, start.getLabel());
    }

    public MyAbstractInsnNode clone(final Map labels) {
        return new MyLineNumberNode(line, clone(start, labels));
    }
}
